import wjRequest from '@/service'
import type { IDataType } from '@/service/types'
import type { IAccount, ILoginResult } from './types'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = '/role/'
}

/**
 * 账号登录
 * @param account {IAccount}
 * @returns
 */
export function accountLoginRequest(account: IAccount): any {
  return wjRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

/**
 * 根据 id 请求数据
 * @param id {number}
 * @returns
 */
export function requestUserInfoById(id: number): any {
  return wjRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id
  })
}

/**
 * 根据id请求角色
 * @param id {number}
 * @returns
 */
export function requestUserMenusByRoleId(id: number): any {
  return wjRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}
